<script setup>
import { reactive } from 'vue'
import useViewEvent from '@/core/hooks/useViewEvent'
import attributeApi from '@/api/goods/AttributeApi'

const state = reactive({ 
  visible: false,  
  loading: false, // 加载开关
})
// 表单结构
const original = {
  id: '',
  name: '',
  catalogId: 0,
  catalogName: '',
  idx: 0,
  notes: '',
  options: []
}
// 表单数据
const formState = reactive({})

// 初始化数据
const { InitializeData } = useViewEvent({state: state, remoteFetchData: attributeApi.getFormModelById, formState: formState, original: original })

//向父组件暴露方法和属性
defineExpose({ InitializeData })
</script>
<template>
  <a-drawer
    v-model:visible="state.visible"
    :title="`查看属性信息`"
    placement="right"
    :width="'50%'">
    <template #extra>
      <a-button type="link" @click="state.visible=false">关闭</a-button>
    </template>
    <a-card hoverable>
      <a-spin :spinning="state.loading">
        <a-descriptions :column="1" bordered>
          <a-descriptions-item label="标识">{{ formState.catalogName }}</a-descriptions-item>
          <a-descriptions-item label="名称">{{ formState.name }}</a-descriptions-item>
          <a-descriptions-item label="排序">{{ formState.idx }}</a-descriptions-item>
          <a-descriptions-item label="备注">{{ formState.notes }}</a-descriptions-item>
          <a-descriptions-item label="列表值">{{ formState.options }} </a-descriptions-item>
        </a-descriptions>
      </a-spin>
    </a-card>
  </a-drawer>
</template>